home *** CD-ROM | disk | FTP | other *** search
- /*
- File: DBDMA.h
-
- Contains: Descriptor Based DMA Interfaces
-
- Version: Technology: System 7.5
- Release: Universal Interfaces 3.0d3 on Copland DR1
-
- Copyright: © 1984-1996 by Apple Computer, Inc. All rights reserved.
-
- Bugs?: If you find a problem with this file, send the file and version
- information (from above) and the problem description to:
-
- Internet: apple.bugs@applelink.apple.com
- AppleLink: APPLE.BUGS
-
- */
- #ifndef __DBDMA__
- #define __DBDMA__
-
- #ifndef __CONDITIONALMACROS__
- #include <ConditionalMacros.h>
- #endif
- #ifndef __PCI__
- #include <PCI.h>
- #endif
- #if FOR_SYSTEM8_PREEMPTIVE
- #ifndef __CODEFRAGMENTS__
- #include <CodeFragments.h>
- #endif
- #ifndef __DRIVERSERVICES__
- #include <DriverServices.h>
- #endif
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import on
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- #if FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
- /* This structure defines the standard set of DB-DMA channel registers.*/
- struct DBDMAChannelRegisters {
- unsigned long channelControl;
- unsigned long channelStatus;
- unsigned long commandPtrHi; /* implementation optional*/
- unsigned long commandPtrLo;
- unsigned long interruptSelect; /* implementation optional*/
- unsigned long branchSelect; /* implementation optional*/
- unsigned long waitSelect; /* implementation optional*/
- unsigned long transferModes; /* implementation optional*/
- unsigned long data2PtrHi; /* implementation optional*/
- unsigned long data2PtrLo; /* implementation optional*/
-
- unsigned long reserved1;
- unsigned long addressHi; /* implementation optional*/
- unsigned long reserved2[4];
- unsigned long unimplemented[16];
-
- /* This structure must remain fully padded to 256 bytes.*/
- unsigned long undefined[32];
- };
- typedef struct DBDMAChannelRegisters DBDMAChannelRegisters;
-
- /* These constants define the DB-DMA channel control words and status flags.*/
-
- enum {
- kdbdmaSetRun = 0x80008000,
- kdbdmaClrRun = 0x80000000,
- kdbdmaSetPause = 0x40004000,
- kdbdmaClrPause = 0x40000000,
- kdbdmaSetFlush = 0x20002000,
- kdbdmaSetWake = 0x10001000,
- kdbdmaClrDead = 0x08000000,
- kdbdmaSetS7 = 0x00800080,
- kdbdmaClrS7 = 0x00800000,
- kdbdmaSetS6 = 0x00400040,
- kdbdmaClrS6 = 0x00400000,
- kdbdmaSetS5 = 0x00200020,
- kdbdmaClrS5 = 0x00200000,
- kdbdmaSetS4 = 0x00100010,
- kdbdmaClrS4 = 0x00100000,
- kdbdmaSetS3 = 0x00080008,
- kdbdmaClrS3 = 0x00080000,
- kdbdmaSetS2 = 0x00040004,
- kdbdmaClrS2 = 0x00040000,
- kdbdmaSetS1 = 0x00020002,
- kdbdmaClrS1 = 0x00020000,
- kdbdmaSetS0 = 0x00010001,
- kdbdmaClrS0 = 0x00010000,
- kdbdmaClrAll = 0xFFFF0000
- };
-
-
- enum {
- kdbdmaRun = 0x00008000,
- kdbdmaPause = 0x00004000,
- kdbdmaFlush = 0x00002000,
- kdbdmaWake = 0x00001000,
- kdbdmaDead = 0x00000800,
- kdbdmaActive = 0x00000400,
- kdbdmaBt = 0x00000100,
- kdbdmaS7 = 0x00000080,
- kdbdmaS6 = 0x00000040,
- kdbdmaS5 = 0x00000020,
- kdbdmaS4 = 0x00000010,
- kdbdmaS3 = 0x00000008,
- kdbdmaS2 = 0x00000004,
- kdbdmaS1 = 0x00000002,
- kdbdmaS0 = 0x00000001
- };
-
- /*
- This structure defines the DB-DMA channel command descriptor.
- *** WARNING: Endian-ness issues must be considered when performing load/store! ***
- *** DB-DMA specifies memory organization as quadlets so it is not correct
- *** to think of either the operation or result field as two 16-bit fields.
- *** This would have undesirable effects on the byte ordering within their
- *** respective quadlets. Use the accessor macros provided below.
- */
- struct DBDMADescriptor {
- unsigned long operation; /* cmd || key || i || b || w || reqCount*/
- unsigned long address;
- unsigned long cmdDep;
- unsigned long result; /* xferStatus || resCount*/
- };
- typedef struct DBDMADescriptor DBDMADescriptor;
-
- typedef DBDMADescriptor *DBDMADescriptorPtr;
- /* These constants define the DB-DMA channel command operations and modifiers.*/
-
- enum {
- /* Command.cmd operations*/
- OUTPUT_MORE = 0x00000000,
- OUTPUT_LAST = 0x10000000,
- INPUT_MORE = 0x20000000,
- INPUT_LAST = 0x30000000,
- STORE_QUAD = 0x40000000,
- LOAD_QUAD = 0x50000000,
- NOP_CMD = 0x60000000,
- STOP_CMD = 0x70000000,
- kdbdmaCmdMask = 0xF0000000
- };
-
-
- enum {
- /* Command.key modifiers (choose one for INPUT, OUTPUT, LOAD, and STORE)*/
- KEY_STREAM0 = 0x00000000, /* default modifier*/
- KEY_STREAM1 = 0x01000000,
- KEY_STREAM2 = 0x02000000,
- KEY_STREAM3 = 0x03000000,
- KEY_REGS = 0x05000000,
- KEY_SYSTEM = 0x06000000,
- KEY_DEVICE = 0x07000000,
- kdbdmaKeyMask = 0x07000000, /* Command.i modifiers (choose one for INPUT, OUTPUT, LOAD, STORE, and NOP)*/
- kIntNever = 0x00000000, /* default modifier*/
- kIntIfTrue = 0x00100000,
- kIntIfFalse = 0x00200000,
- kIntAlways = 0x00300000,
- kdbdmaIMask = 0x00300000, /* Command.b modifiers (choose one for INPUT, OUTPUT, and NOP)*/
- kBranchNever = 0x00000000, /* default modifier*/
- kBranchIfTrue = 0x00040000,
- kBranchIfFalse = 0x00080000,
- kBranchAlways = 0x000C0000,
- kdbdmaBMask = 0x000C0000, /* Command.w modifiers (choose one for INPUT, OUTPUT, LOAD, STORE, and NOP)*/
- kWaitNever = 0x00000000, /* default modifier*/
- kWaitIfTrue = 0x00010000,
- kWaitIfFalse = 0x00020000,
- kWaitAlways = 0x00030000,
- kdbdmaWMask = 0x00030000, /* operation masks*/
- kdbdmaCommandMask = 0xFFFF0000,
- kdbdmaReqCountMask = 0x0000FFFF
- };
-
- /* These constants define the DB-DMA channel command results.*/
-
- enum {
- kXferStatusRun = kdbdmaRun << 16,
- kXferStatusPause = kdbdmaPause << 16,
- kXferStatusFlush = kdbdmaFlush << 16,
- kXferStatusWake = kdbdmaWake << 16,
- kXferStatusDead = kdbdmaDead << 16,
- kXferStatusActive = kdbdmaActive << 16,
- kXferStatusBt = kdbdmaBt << 16,
- kXferStatusS7 = kdbdmaS7 << 16,
- kXferStatusS6 = kdbdmaS6 << 16,
- kXferStatusS5 = kdbdmaS5 << 16,
- kXferStatusS4 = kdbdmaS4 << 16,
- kXferStatusS3 = kdbdmaS3 << 16,
- kXferStatusS2 = kdbdmaS2 << 16,
- kXferStatusS1 = kdbdmaS1 << 16,
- kXferStatusS0 = kdbdmaS0 << 16, /* result masks*/
- kdbdmaResCountMask = 0x0000FFFF,
- kdbdmaXferStatusMask = kdbdmaResCountMask << 16
- };
-
- #if FOR_SYSTEM8_PREEMPTIVE
- typedef void *DBDMAChannelConnectionPtr;
- /*
- /////////////////////////////////////////////////////////////////////////////////
- Channel Connections
- */
- extern OSStatus OpenDBDMAChannel(DBDMAChannelRegisters *DBDMAPtr, DBDMAChannelConnectionPtr *channelConnection, UInt32 cclNum, LogicalAddress *logicalAddr, PhysicalAddress *physicalAddr);
-
- extern void CloseDBDMAChannel(DBDMAChannelConnectionPtr channelConnection);
-
- /*
- /////////////////////////////////////////////////////////////////////////////////
- Client Buffer Assignment
- */
- extern void SetDBDMAPhysicalAddress(DBDMAChannelConnectionPtr channelConnection, Boolean isReadTransfer, PhysicalAddress addressPtr, ByteCount transferCount);
-
- /*
- /////////////////////////////////////////////////////////////////////////////////
- Channel Control Operations
- */
- extern void StartDBDMA(DBDMAChannelConnectionPtr channelConnection);
-
- extern void StopDBDMA(DBDMAChannelConnectionPtr channelConnection);
-
- extern void ResetDBDMA(DBDMAChannelConnectionPtr channelConnection);
-
- extern void PrepDBDMA(DBDMAChannelConnectionPtr channelConnection);
-
- #endif
- #if FOR_SYSTEM8_PREEMPTIVE
- #define NOP() SynchronizeIO()
- #define SYNC() SynchronizeIO()
- #endif
-
- /* These macros are are DBDMAChannelRegisters accessor functions. */
-
- /* void SetChannelControl (DBDMAChannelRegisters *registerSetPtr, unsigned long ctlValue); */
- #define SetChannelControl(registerSetPtr,ctlValue) \
- (NOP(), (registerSetPtr)->channelControl = EndianSwap32Bit(ctlValue), NOP())
-
-
- /* unsigned long GetChannelStatus (DBDMAChannelRegisters *registerSetPtr); */
- #define GetChannelStatus(registerSetPtr) \
- (EndianSwap32Bit((registerSetPtr)->channelStatus))
-
-
- /* unsigned long GetCommandPtr (DBDMAChannelRegisters *registerSetPtr); */
- #define GetCommandPtr(registerSetPtr) \
- (EndianSwap32Bit((registerSetPtr)->commandPtrLo))
-
- /* void SetCommandPtr (DBDMAChannelRegisters *registerSetPtr, unsigned long cclPtr); */
- #define SetCommandPtr(registerSetPtr,cclPtr) \
- ((registerSetPtr)->commandPtrLo = EndianSwap32Bit(cclPtr), NOP())
-
-
- /* unsigned long GetInterruptSelect (DBDMAChannelRegisters *registerSetPtr); */
- #define GetInterruptSelect(registerSetPtr) \
- (EndianSwap32Bit((registerSetPtr)->interruptSelect))
-
- /* void SetInterruptSelect (DBDMAChannelRegisters *registerSetPtr, unsigned long intSelValue); */
- #define SetInterruptSelect(registerSetPtr,intSelValue) \
- ((registerSetPtr)->interruptSelect = EndianSwap32Bit(intSelValue), NOP())
-
-
- /* unsigned long GetBranchSelect (DBDMAChannelRegisters *registerSetPtr); */
- #define GetBranchSelect(registerSetPtr) \
- (EndianSwap32Bit((registerSetPtr)->branchSelect))
-
- /* void SetBranchSelect (DBDMAChannelRegisters *registerSetPtr, unsigned long braSelValue); */
- #define SetBranchSelect(registerSetPtr,braSelValue) \
- ((registerSetPtr)->branchSelect = EndianSwap32Bit(braSelValue), NOP())
-
-
- /* unsigned long GetWaitSelect (DBDMAChannelRegisters *registerSetPtr); */
- #define GetWaitSelect(registerSetPtr) \
- (EndianSwap32Bit((registerSetPtr)->waitSelect))
-
- /* void SetWaitSelect (DBDMAChannelRegisters *registerSetPtr, unsigned long waitSelValue); */
- #define SetWaitSelect(registerSetPtr,waitSelValue) \
- ((registerSetPtr)->waitSelect = EndianSwap32Bit(waitSelValue), NOP())
-
- /* These macros are DBDMADescriptor accessor functions. */
-
- /* void MakeCCDescriptor (DBDMADescriptor *descPtr, */
- /* unsigned long op, unsigned long addr); */
- #define MakeCCDescriptor(descPtr,op,addr) \
- ((descPtr)->address = EndianSwap32Bit(addr), \
- (descPtr)->cmdDep = 0, \
- (descPtr)->result = 0, \
- SYNC(), \
- (descPtr)->operation = EndianSwap32Bit(op), \
- SYNC())
-
- /* void MakeCmdDepCCDescriptor (DBDMADescriptor *descPtr, */
- /* unsigned long op, unsigned long addr, unsigned long dep); */
- #define MakeCmdDepCCDescriptor(descPtr,op,addr,dep) \
- ((descPtr)->address = EndianSwap32Bit(addr), \
- (descPtr)->cmdDep = EndianSwap32Bit(dep), \
- (descPtr)->result = 0, \
- SYNC(), \
- (descPtr)->operation = EndianSwap32Bit(op), \
- SYNC())
-
- /* unsigned long GetCCOperation (DBDMADescriptor *descPtr) */
- #define GetCCOperation(descPtr) \
- (EndianSwap32Bit((descPtr)->operation))
-
- /* void SetCCOperation (DBDMADescriptor *descPtr, unsigned long operationValue) */
- #define SetCCOperation(descPtr,operationValue) \
- ((descPtr)->operation = EndianSwap32Bit(operationValue))
-
-
- /* unsigned long GetCCAddress (DBDMADescriptor *descPtr) */
- #define GetCCAddress(descPtr) \
- (EndianSwap32Bit((descPtr)->address))
-
- /* void SetCCAddress (DBDMADescriptor *descPtr, unsigned long addressValue) */
- #define SetCCAddress(descPtr,addressValue) \
- ((descPtr)->address = EndianSwap32Bit(addressValue))
-
-
- /* unsigned long GetCCCmdDep (DBDMADescriptor *descPtr) */
- #define GetCCCmdDep(descPtr) \
- (EndianSwap32Bit((descPtr)->cmdDep))
-
- /* void SetCCCmdDep (DBDMADescriptor *descPtr, unsigned long cmdDepValue) */
- #define SetCCCmdDep(descPtr,cmdDepValue) \
- ((descPtr)->cmdDep = EndianSwap32Bit(cmdDepValue))
-
- /* unsigned long GetCCResult (DBDMADescriptor *descPtr) */
- #define GetCCResult(descPtr) \
- (EndianSwap32Bit((descPtr)->result))
-
- /* void SetCCResult (DBDMADescriptor *descPtr, unsigned long resultValue) */
- #define SetCCResult(descPtr,resultValue) \
- ((descPtr)->result = EndianSwap32Bit(resultValue))
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import off
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __DBDMA__ */
-
-